<template>
	<view class="content">
		<view class="title">
			昵称
		</view>
		<view class="inputbox">
			<input type="text" v-model="text" placeholder="请输入昵称（少于10字）" />
		</view>
		<view class="mybtn" @click="make">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text:'',
			}
		},
		onLoad() {

		},
		methods: {
			make(){
				if(this.text !=''){
					var token =uni.getStorageSync('token')
					if(token==''||token==null){
						uni.reLaunch({
						    url:'../../login/login'
						})
					}else{
						this.http({
						 	url:'/api/User/upNickAndAvantar',
						 	method:'POST',
							header:{
								'token':token
							},
							data:{
								text:this.text,
							},
						 	success:(res)=>{
								console.log(res)
								uni.showToast({
									title:res.msg,
									icon:'none'
								})
								if(res.code ==1){
									uni.switchTab({
										url:'../me'
									})
								}else{
									this.text==''
								}
							},
						 	error:()=>{
						 		uni.showToast({
						 			title:"请求异常"	
						 		})
						 	},	
						 })
					} 
				}else{
					uni.showToast({
						title:'信息不能为空',
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC;
		font-weight: 500;
		color:#2b2b2b;
		padding-bottom: 50rpx;
		.title{
			width: 690rpx;
			font-size: 32rpx;
			font-weight: bold;
			text-indent: 1rem;
		}
		.inputbox{
			width: 630rpx;
			height: 98rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 2px 0px rgba(43, 43, 43, 0.18);
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			padding: 0 30rpx;
			margin: 20rpx auto;
			input{
				flex: 1;
			}
		}
		.mybtn{
			width: 690rpx;
			height: 88rpx;
			background: #0072FF;
			border-radius: 10rpx;
			text-align: center;
			margin: 30rpx auto;
			font-size: 36rpx;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 88rpx;
		}
		
	}

	
</style>
